package com.example.demo.json;

import com.alibaba.fastjson.JSON;
import com.example.demo.CAUtil;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/** @author haijianxia pure_xhj@163.com @Date 2021-10-28 @Time 17:09 */
public class TestDemo {

  public static void main(String[] args) {
    String s = CAUtil.toBase64FromURL("http://localhost:8080/file.pdf");
    DemoEntity demoEntity = new DemoEntity(s);
    String jsonString1 = JSON.toJSONString(demoEntity);
    //
    DemoEntity demoEntity1 = JSON.parseObject(jsonString1, DemoEntity.class);
    String str = demoEntity1.str;

    System.out.println("====================================================");
    List<DemoEntity> list2 = new ArrayList<>();
    list2.add(new DemoEntity("qwer"));
    list2.add(new DemoEntity(("asdf")));
    list2.add(new DemoEntity("zxcv"));
    String jsonString = JSON.toJSONString(list2);
    System.out.println("jsonString = " + jsonString);
    ArrayList arrayList = JSON.parseObject(jsonString, ArrayList.class);
    if (null == arrayList) {
      System.out.println(" = null ");
    }

    System.out.println("====================================================");
    long time01 = System.currentTimeMillis();
    CAUtil.toBase64FromURL(
        "http://s3.caiwu.corp/gbcfapp-public-read/spiderman/af5cdbeb15a74bd4bb81d6c15f13bb28.jpg");
    CAUtil.toBase64FromURL(
        "http://s3.caiwu.corp/gbcfapp-public-read/spiderman/af5cdbeb15a74bd4bb81d6c15f13bb28.jpg");
    CAUtil.toBase64FromURL(
        "http://s3.caiwu.corp/gbcfapp-public-read/spiderman/af5cdbeb15a74bd4bb81d6c15f13bb28.jpg");
    System.out.println(
        "=================耗时:[{}]================" + (System.currentTimeMillis() - time01));

    System.out.println("====================================================");
    long l = System.currentTimeMillis();
    System.out.println("====================================================");
    Set<Long> set = new HashSet<>();
    set.add(1L);
    boolean contains = set.contains(new Integer(1).longValue());
    boolean contains1 = set.contains(1);
    boolean contains2 = set.contains(1l);
    System.out.println("====================================================");
    List<Integer> list = new ArrayList<>();
    add(list);
    int size = list.size();
  }

  public static void add(List list) {
    list.add(1);
  }
}
